/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.lucene.spatial.tier;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Shape contains information related to a shape created on a specific cartesian
 * tier. Because the tiers consist of a set of boxes, shapes are defined simply
 * by what boxes the shape overlaps, and what tier level the boxes are at. Such
 * a simply approximation will result in points being included that are not in
 * the actual shape, but this fine grained filtering is left out of the
 * cartesian shape filtering process.
 */
public class Shape implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final List<Double> boxIds = new ArrayList<Double>();
	private final int tierId;

	/**
	 * Creates a new Shape that represents a shape at the given tier level
	 * 
	 * @param tierId
	 *            ID of the tier level that the shape is in
	 */
	public Shape(int tierId) {
		this.tierId = tierId;
	}

	/**
	 * Adds the given box id to the list of boxes this shape overlaps
	 * 
	 * @param boxId
	 *            ID of a box that this shape overlaps
	 */
	public void addBox(double boxId) {
		boxIds.add(boxId);
	}

	// ================================================= Getters / Setters
	// =============================================

	/**
	 * Returns the tier level ID that this shape is in
	 * 
	 * @return Tier level id that this shape is in
	 */
	public int getTierID() {
		return tierId;
	}

	/**
	 * Returns the list of ids of the boxes that this shape overlaps
	 * 
	 * @return List of ids of the boxes the shape overlaps. Always non-null.
	 */
	public List<Double> getBoxIds() {
		return boxIds;
	}
}
